package com.completecompute;
import com.DTC.Divide;
import com.DTC.LoadData;
import com.DTC.D;
import com.fourinone.MigrantWorker;
import com.fourinone.WareHouse;

public class WorkerDemo extends MigrantWorker
{
	private String workname;
	public WorkerDemo(String workname)
	{
		this.workname = workname;
	}
	
	public WareHouse doTask(WareHouse inhouse)
	{
		D d = (D)inhouse.get("D");
		if(d.name==-1){
			System.out.println("完成了任务");
			return new WareHouse("D",d);
		}
		try {
			Thread.sleep(200);
		} catch (Exception e) {
			// TODO: handle exception
		}
		System.out.println("获得了任务"+d.name);
		LoadData loadData = new LoadData("data/iris.data");
		Divide divide = new Divide(d.getData(), d.getAttrIndex());
		d.gain=divide.gain;
		d.mid=divide.mid;
		d.setState(2);
		// attr2int
		// Divide 
		// LoadData loadData = new LoadData("data/iris.data");
		// Divide divide = new Divide(loadData.irisTrain, intv);
		// try{
		// 	System.out.println("divide"+divide.gain+"  "+divide.mid);
		// }catch(Exception e){

		// }

		// Divide divide = new Divide(data, parallelPatternFlag)
		System.out.println("完成了任务");
		return new WareHouse("D",d);
	}
	
	public static void main(String[] args)
	{
		WorkerDemo wd = new WorkerDemo(args[0]);
		wd.waitWorking("localhost",Integer.parseInt(args[1]),"workdemo");
	}
}